package com.t2t.top.thread.future;

import com.t2t.top.thread.DateUtils;

/**
 * Created by yangpengfei on 2016/11/30.
 */
public class Client {
    public Data requst(final String queryStr) {
        final FutureData futureData = new FutureData();

        new Thread() {
            @Override
            public void run() {
                RealData realData = new RealData(queryStr);
                futureData.setRealData(realData);
            }
        }.start();

        return futureData;
    }

    public static void main(String[] args) {
        Client client = new Client();
        Data data = client.requst("ypf");
        System.out.println(client.requst("abc").getResult());
        System.out.println("1请求完毕=>" + DateUtils.getDateStr());

        System.out.println(client.requst("123").getResult());
        System.out.println("2请求完毕=>" + DateUtils.getDateStr());
        System.out.println("结果=" + data.getResult() + "=>" + DateUtils.getDateStr());
    }
}
